<?php
namespace Admin\Controller;
use Admin\Base\BaseController;
use Admin\Model\PhManagerModel;
use Admin\Logic\Controller\MainController;

class PhManagerController extends MainController {
    public function index(){
        $this->display();
    }
    public function innerManager(){
        $this->display();
    }
    public function outManager(){
        $this->display();
    }
    protected $phManagerModel = null;
    public function _initialize(){
        $this->phManagerModel = new PhManagerModel();
    }
    //添加院内类型
    public function addHospitalType(){
        $data['sub_type'] = I('post.sub_type');
        $data['server_type'] = I('server_type');
        $data['remark'] = I('post.remark');
        $data['hid'] = I('post.hid');
        $data['price'] = I('post.price');
        $data['num'] = I('post.num');
        $data['num_type'] = I('post.num_type');
        $data['sort'] = I('post.array');
        $idGourp = array();
        //$data['special'] = I('post.special');
        foreach (I('post.special') as $item) {
           $special['name'] = $item['name'];
           $special['sort'] = $item['array'];
           $special['remark'] = $item['remark'];
           $special['rule'] = $item['rule'];
           $special['hid'] = $data['hid'];
           $special['rule_price'] = $item['value'];
           array_push($idGourp,$this->phTypeModel->add_hospital_group($special));
        }
        $data['special_group'] = implode(',',$idGourp); 
        $res = $this->phManagerModel->add_hospital_type($data);
        if($res){
            $this->_exit($res,'请求成功',1);
        }else{
             $this->_exit($res,'请求失败',0);
        }
    }
    //得到住院类型列表
    public function getHospitalType(){
        $data = I('post.hid');
        $res = $this->phManagerModel->get_hospital_type($data);
        if($res){
            $this->_exit($res,'请求成功',1);
        }else{
             $this->_exit($res,'请求失败',0);
        }
    }
}